package com.srd.phone.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.shengrongdai.srd.R;
import com.srd.phone.bean.HPayment;
import com.srd.phone.utils.views.ViewHolder;

import java.util.ArrayList;
import java.util.List;

public class ReturnMoneyRecordAdapter extends BaseAdapter {

    private Context context;
    private List<HPayment> list = new ArrayList<HPayment>(10);

    public ReturnMoneyRecordAdapter(Context context, List<HPayment> list0) {
        this.context = context;
        list = list0;
    }

    public void setData(List<HPayment> list0) {
        list = list0;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public HPayment getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return 0;
    }

    @Override
    public View getView(int position, View view, ViewGroup parent) {
        ViewHolder viewHolder =  ViewHolder.get(context, view, parent, R.layout.item_return_money_record, position);

        HPayment item = getItem(position);
        TextView tv_name = viewHolder.getView(R.id.tv_name);
        tv_name.setText(item.bnm);

        TextView tv_money = viewHolder.getView(R.id.tv_money);
        tv_money.setText(item.monrey + "元");

        TextView tv_mode = viewHolder.getView(R.id.tv_mode);
        tv_mode.setText(item.numbersm);

        TextView tv_num = viewHolder.getView(R.id.tv_num);
        tv_num.setText(item.num + "");

        TextView tv_date = viewHolder.getView(R.id.tv_date);
        tv_date.setText(item.ptime);

        return viewHolder.getConvertView();
    }
}
